package org.paboo.util;

import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;

/**
 * Logger Factory Utils
 *
 * @author Leonard Woo
 */
public class LoggerFactoryUtils {
    private static LoggerFactoryUtils ourInstance = new LoggerFactoryUtils();
    private Logger logger;

    public static LoggerFactoryUtils getInstance() {
        return ourInstance;
    }

    private LoggerFactoryUtils() {
    }

    public LoggerFactoryUtils load(Class<?> clazz) {
        logger = LogManager.getLogger(clazz);
        return this;
    }

    public void debug(String s) {
        if (logger.isDebugEnabled()) {
            logger.debug(s);
        }
    }

    public void debug(String s, Throwable t) {
        if (logger.isDebugEnabled()) {
            logger.debug(s, t);
        }
    }

    public boolean isDebugEnabled(){
        return logger.isDebugEnabled();
    }

    public void info(String s) {
        if (logger.isInfoEnabled()) {
            logger.info(s);
        }
    }

    public void info(String s, Throwable t) {
        if (logger.isInfoEnabled()) {
            logger.info(s, t);
        }
    }

    public void warn (String s) {
        if (logger.isWarnEnabled()) {
            logger.warn(s);
        }
    }

    public void warn (String s, Throwable t) {
        if (logger.isWarnEnabled()) {
            logger.warn(s, t);
        }
    }

    public void error (String s) {
        if (logger.isErrorEnabled()) {
            logger.error(s);
        }
    }

    public void error (String s, Throwable t) {
        if (logger.isErrorEnabled()) {
            logger.error(s, t);
        }
    }

    public void error (Throwable t) {
        if (logger.isErrorEnabled()) {
            logger.error(t);
        }
    }

    public void trace(String s){
        if (logger.isTraceEnabled()) {
            logger.trace(s);
        }
    }

    public void trace(String s, Throwable t){
        if (logger.isTraceEnabled()) {
            logger.trace(s, t);
        }
    }

}
